﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows;

namespace MaskDemo
{
    public static class PopupService
    {
        public static void Show(FrameworkElement content,
                               Action closeCallback = null,
                               Brush maskBrush = null,
                               bool closeOnClickMask = true)
        {
            var rootElement = Application.Current.MainWindow.Content as FrameworkElement;
            var layer = AdornerLayer.GetAdornerLayer(rootElement);

            var adorner = new PopupAdorner(rootElement, content)
            {
                CloseCallback = closeCallback,
                MaskBrush = maskBrush ?? new SolidColorBrush(Color.FromArgb(180, 0, 0, 0)),
                CloseOnClickMask = closeOnClickMask
            };

            layer.Add(adorner);
        }
    }
}
